from django.db import models
from vistor.models import Users
from schoolmaster.models import *
# Create your models here.
Sex = (
    (1, '未知'),
    (2, '男'),
    (3, '女'),
)


class Parents(models.Model):
    uphone = models.CharField(max_length=11, verbose_name='电话')
    familyrole = models.CharField(max_length=10, null=True, verbose_name='家庭角色')

    # 与Users表(1:1)
    user = models.OneToOneField(Users, verbose_name='身份')
    # 与School表(m:1)
    school = models.ForeignKey(School, verbose_name='园所')
    # 与Student表(m:1)
    student = models.ForeignKey(Student, verbose_name='宝宝')

    def __str__(self):
        return self.familyrole

    class Meta:
        db_table = 'parents'
        verbose_name = '家长表'
        verbose_name_plural = verbose_name


class Growth(models.Model):
    gender = models.IntegerField(choices=Sex, default='1', verbose_name='性别')
    monthage = models.IntegerField(null=False, verbose_name='月龄')
    picture = models.ImageField(upload_to='static/grow_img', null=False, verbose_name='养育图')
    isDelete = models.BooleanField(default=False, verbose_name='删除')
    def __str__(self):
        return str(self.monthage)

    class Meta:
        db_table = 'growing'
        verbose_name = '养育表'
        verbose_name_plural = verbose_name


# 点赞分享表
class Commend(models.Model):
    like = models.IntegerField(default=100, null=True,  verbose_name='点赞')
    share = models.IntegerField(default=100, null=True,  verbose_name='分享')

    # 与Video(1:1)
    video = models.OneToOneField(Video, verbose_name='视频')

    def __str__(self):
        return self.video.title

    class Meta:
        db_table = 'commend'
        verbose_name = '视频点赞分享表'
        verbose_name_plural = verbose_name


# 视频评论表
class Review(models.Model):
    comment = models.CharField(max_length=150, null=True, verbose_name='评论')

    # 与Video(m:1)
    video = models.ForeignKey(Video, verbose_name='视频')
    # 与Parents(m:1)
    parent = models.ForeignKey(Parents, verbose_name='用户')

    def __str__(self):
        return self.comment

    class Meta:
        db_table = 'review'
        verbose_name = '视频评论表'
        verbose_name_plural = verbose_name
